#include "projectHeader.h"

int getMenu ( int isIns, int isStu )
{
    int nOpt;

    if ( isIns )
    {
        for ( nOpt = 0; nOpt < 1 || nOpt > 9; )
        {
            printf ( "\n------------Instructor Menu------------\n" );
            printf ( "1.Add a student\n" );
            printf ( "2.Add an instructor\n" );
            printf ( "3.Change the info of a student\n" );
            printf ( "4.Change the info of an instructor\n" );
            printf ( "5.Delete a student\n" );
            printf ( "6.Delete an instructor\n" );
            printf ( "7.Show class\n" );
            printf ( "8.Save and log out\n" );
            printf ( "9.Save and exit program\n");
            printf ( "Please select an option: " );
            scanf ( "%d", &nOpt );

            if ( nOpt < 1 || nOpt > 10 )
                printf ( "Option Error: No such option!\n" );
        }
    }
    else if ( isStu )
    {
        for ( nOpt = 0; nOpt < 1 || nOpt > 4; )
        {
            printf ( "\n-------------Student Menu-------------\n" );
            printf ( "1.Find my score\n" );
            printf ( "2.Get average score of the class\n" );
            printf ( "3.Logout\n" );
            printf ( "4.Exit program\n");
            printf ( "Please select an option: " );
            scanf ( "%d", &nOpt );

            if ( nOpt < 1 || nOpt > 4 )
                printf ( "Option Error: No such option!\n" );
            else if ( nOpt == 3 )
                return 0;
        }
    }
    else
    {
        printf ( "Sorry, you are not the member of this class!\n" );
        printf ( "Log in user: ");
        /* if not a student or an instructor, show notification */
        return 0;
    }

    return nOpt;
}

void exitProg ()
{
    printf ( "\nThank you for using it!\n" );
    printf ( "Designed by KisonHo (Qisheng He)\nV2.1f\n" );
    exit ( 1 );
}
